﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Runtime.Serialization;

namespace Vision.Core.Entities.Scheduling
{
    /// <summary>
    /// 
    /// </summary>        
    [Serializable()]
    [DataContract()]
    public class VisionActvitySchedule
    {
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public int Id { get; set; }
        
        /// <summary>
        /// 
        /// </summary>                                        
        [DataMember]
        public Guid Key { get; set; }
                        
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public string Description { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public Guid ActivityKey { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public string ActivityQueue { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public Activities.VisionActivityParameterCollection ActivityParams { get; set; }
                                        
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public ScheduleTypes ScheduleType { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public Nullable<DateTime> ScheduleNextRunDate { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public Nullable<DateTime> ScheduleLastRunDate { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public DateTime ScheduleStartDate { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public DateTime ScheduleFinishDate { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public bool ScheduleCanExpire { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public TimeSpan RepeatEvery { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public ScheduleWeekDays RunOnWeekDays { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public ScheduleMonths RunOnMonths { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public int RunOnDays { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public ScheduleRunOnDayOccurences RunOnDayOccurences { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public bool Active { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public DateTime Created { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public string LastError { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public DateTime Modified { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public VisionActvitySchedule()
        {
            //Defualts
            DateTime timeStamp = DateTime.Now;
            this.Key = Guid.NewGuid();            
            this.ActivityParams = new Activities.VisionActivityParameterCollection();
            this.Active = true;
            this.ScheduleStartDate = timeStamp;
            this.ScheduleNextRunDate = null;
            this.ScheduleLastRunDate = null;
            this.ScheduleFinishDate = timeStamp;
            this.LastError = string.Empty;
            this.Created = timeStamp;
            this.Modified = timeStamp;
        }
    }
}
